<?php


namespace Modules\Common\Exceptions;
use Modules\Common\Helpers\ApiCode;
use Exception;
use Throwable;

class BaseException extends Exception
{
    public $http_code = 200;
    public $message;
    public $code;
    public function __construct($message = "", $code = 0, $http_code = 200, Throwable $previous = null) {
        if (!empty($message)) {
            $this->message = $message;
        }
        if (!empty($code)) {
            $this->code = $code;
        }
        if (!empty($http_code)) {
            $this->http_code = $http_code;
        }
        if (empty($this->message)) {
            $this->message = ApiCode::getDescription($this->code);
        }
        parent::__construct($this->message, $this->code, $previous);
    }
    public function getHttpCode() {
        return $this->http_code;
    }
}
